<template>
  <div>
    <el-dialog
      title="测试成绩编辑"
      :visible.sync="dialogVisible"
      width="40%"
      :before-close="handleClose"
    >
      <el-form
        label-position="right"
        label-width="120px"
        :model="formLabelAlign"
      >
        <el-form-item label="学号：">
          <el-input v-model="formLabelAlign.number"></el-input>
        </el-form-item>
        <el-form-item label="班级：">
          <el-input v-model="formLabelAlign.class"></el-input>
        </el-form-item>
        <el-form-item label="姓名：">
          <el-input v-model="formLabelAlign.name"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { mapState } from "vuex";
import axios from "axios";
export default {
  components: {},
  props: {
    // formLabelAlign: {
    //   default: () => {
    //     return {
    //       number: "",
    //       class: "",
    //       name: "",
    //     };
    //   },
    // },
    dataId: {
      default: () => "",
    },
  },
  data() {
    return {
      dialogVisible: false,
      formLabelAlign: {
        number: "",
        class: "",
        name: "",
      },
    };
  },
  computed: {
    ...mapState({}),
  },
  watch: {},
  updated() {
    console.log(this.formLabelAlign);
  },
  beforeDestroy() {},
  created() {},
  methods: {
    handleClose() {
      this.dialogVisible = false;
      this.$message({
        type: "warning",
        message: "已取消编辑",
      });
    },
    openDialog() {
      this.dialogVisible = true;
    },
    submit() {
      console.log(this.formLabelAlign);
      let studentid = this.formLabelAlign.number;
      let name = this.formLabelAlign.name;
      let nation = this.formLabelAlign.class;
      let studentId = this.dataId;
      console.log(studentid, name, nation, studentId);
      axios
        .post("/api/user/updateStuInfo", {
          studentid,
          name,
          nation,
          studentId,
        })
        .then((res) => {
          console.log(res);
        });
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-button {
  position: static !important;
}
/deep/ .el-dialog {
  .el-dialog__header {
    background: #143853 !important;
  }
  .el-dialog__title {
    color: #ffffff;
  }
  .el-dialog__body {
    color: #ffffff;
    padding-bottom: 20px;
    background: #0f2d43 !important;
  }
  .el-dialog__footer {
    padding-right: 40px;
    background: #0f2d43;
  }
  .el-form-item__label {
    color: #ffffff;
  }
  .el-input__inner {
    width: 100%;
    background: #0355a4 !important;
    border: none;
    color: #ffffff;
  }
}
.main {
  display: flex;
}
</style>